import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed  constantRouterMap
 */
export const constantRouterMap = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },

  //根目录
  {
    path: "/",
    component: Layout,
    redirect: "/welcome",
    hidden: true
  },

  {
    path: "/welcome",
    component: Layout,
    children: [
      {
        path: "/",
        name: "",
        component: () => import("@/views/back/welcome"),
        meta: { title: "首页", icon: "table" }
      }
    ]
  },

  {
    path: "/peizhihua",
    component: Layout,
    redirect: "/peizhihua/zishiying",
    meta: { title: "配置化", icon: "table" },
    children: [
      {
        path: "list",
        name: "",
        component: () => import("@/views/peizhihua/list"),
        meta: { title: "列表", icon: "table" }
      },
      {
        path: "zishiying/:dapingid",
        name: "",
        component: () => import("@/views/peizhihua/zishiying"),
        meta: { title: "自适应布局", icon: "table" }
      },
      {
        path: "jueduibuju/:dapingid",
        name: "",
        component: () => import("@/views/peizhihua/jueduibuju"),
        meta: { title: "绝对布局", icon: "table" }
      },
      {
        path: "sanweichangjing/:dapingid",
        name: "",
        component: () => import("@/views/peizhihua/earthui"),
        meta: { title: "三维场景编辑", icon: "table" }
      },
      {
        path: "sanweiditu/:dapingid",
        name: "",
        component: () => import("@/views/peizhihua/sanweipeizhi"),
        meta: { title: "三维地图配置化", icon: "table" }
      },
      {
        path: "shujuyuan",
        name: "",
        component: () => import("@/views/peizhihua/shujuyuan"),
        meta: { title: "数据源", icon: "table" }
      },
      {
        path: "ziyuan",
        name: "",
        component: () => import("@/views/peizhihua/ziyuan"),
        meta: { title: "资源管理", icon: "table" }
      },
    ]
  },

  //编辑器预览
  {
    path: "/yulan/:dapingid",
    component: () => import("@/views/peizhihua/yulan"),
    name: "yulan",
    meta: { title: "郑州", icon: "example" ,name : "zhengzhou"},
    hidden: true
  },

  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true
  }

  // {
  //   path: '/cesium',
  //   component: () => import('@/views/cesium/layout'),
  //   redirect: '/cesium/index',
  //   name: 'map',
  //   meta: { title: 'cesium地图', icon: 'tree' },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'index',
  //       component: () => import('@/views/cesium'),
  //       meta: { title: 'cesium地图1', icon: 'user' }
  //     },]
  // },
];

export const asyncRouterMap = [
  //监控主页路由
  //  {
  //    path: "/home",
  //    component: () => import("@/views/home"),
  //    name: "home",
  //    meta: { title: "监控主页", icon: "example" },
  //    // hidden: true
  //    children: [
  //      {
  //        path: "/",
  //        name: "/",
  //        component: () => import("@/views/home/homePage/index"),
  //        meta: { title: "首页", icon: "table" },
  //        hidden: true
  //      },
  //      {
  //        path: "index",
  //        name: "index",
  //        component: () => import("@/views/home/homePage/index"),
  //        meta: { title: "监控主页首页", icon: "table" },
  //        hidden: true
  //      },
  //      {
  //        path: "etc",
  //        name: "ETC门架",
  //        component: () => import("@/views/home/etc"),
  //        meta: { title: "设备分类", icon: "table" },
  //        hidden: true
  //      },
  //      {
  //        path: "cost",
  //        name: "收费广场",
  //        component: () => import("@/views/home/cost"),
  //        meta: { title: "设备分类", icon: "table" },
  //        hidden: true
  //      },
  //      {
  //        path: "server",
  //        name: "机房",
  //        component: () => import("@/views/home/server"),
  //        meta: { title: "设备分类", icon: "table" },
  //        hidden: true
  //      }
  //    ]
  //  },

  //日志管理路由
  {
    path: "/logs",
    name: "logs",
    meta: { title: "日志管理", icon: "table" },
    component: Layout,
    alwaysShow: true,
    redirect: "/logs/system",
    children: [
      {
        path: "system",
        name: "system",
        component: () => import("@/views/back/log/system"),
        meta: { title: "系统日志", icon: "table" }
      }
    ]
    // hidden: true
  },

  {
    path: "/ums",
    component: Layout,
    redirect: "/ums/admin",
    name: "ums",
    meta: { title: "权限", icon: "tree" },
    children: [
      {
        path: "admin",
        name: "admin",
        component: () => import("@/views/back/permissions/admin/index"),
        meta: { title: "用户列表", icon: "user" }
      },
      {
        path: "role",
        name: "role",
        component: () => import("@/views/back/permissions/role/index"),
        meta: { title: "角色列表", icon: "fanshe" }
      },
      {
        path: "menu",
        name: "menu",
        component: () => import("@/views/back/permissions/menu/index"),
        meta: { title: "菜单列表", icon: "shebeiguanli" }
      },
      {
        path: "resource",
        name: "resource",
        component: () => import("@/views/back/permissions/resource/index"),
        meta: { title: "资源列表", icon: "chucun" }
      },
      {
        path: "resourceCategory",
        name: "resourceCategory",
        component: () =>
          import("@/views/back/permissions/resource/categoryList"),
        meta: { title: "资源分类" },
        hidden: true
      }
    ]
  },

  //郑州
  {
    path: "/zhengzhou",
    component: () => import("@/views/tongyong"),
    name: "zhengzhou",
    meta: { title: "郑州", icon: "example" ,name : "zhengzhou"}
    // hidden: true
  },

  //郑州_T
  {
    path: "/zhengzhou_t",
    component: () => import("@/views/tongyong"),
    name: "zhengzhou_t",
    meta: { title: "郑州_T", icon: "example" ,name : "zhengzhou_t"}
    // hidden: true
  },
  {
    path: "/zhengzhoubanping1",
    component: () => import("@/views/tongyongnn"),
    name: "zhengzhoubanping1",
    meta: { title: "郑州半屏1", icon: "example" ,name : "zhengzhoubanping1"}
    // hidden: true
  },
  {
    path: "/zhengzhoubanping2",
    component: () => import("@/views/tongyongnn"),
    name: "zhengzhoubanping2",
    meta: { title: "郑州半屏2", icon: "example" ,name : "zhengzhoubanping2"}
    // hidden: true
  },

  //郑州_N
  {
    path: "/zhengzhou_n",
    component: () => import("@/views/tongyongnn"),
    name: "zhengzhoun",
    meta: { title: "郑州", icon: "example" ,name : "zhengzhou"}
    // hidden: true
  },

  //玲珑
  {
    path: "/linglong",
    component: () => import("@/views/tongyong"),
    name: "linglong",
    meta: { title: "玲珑", icon: "example" ,name : "linglong"}
    // hidden: true
  },

  //玲珑_T
  {
    path: "/linglong_t",
    component: () => import("@/views/tongyong"),
    name: "linglong_t",
    meta: { title: "玲珑_T", icon: "example" ,name : "linglong_t"}
    // hidden: true
  },

  //二次网仿真
  {
    path: "/ercifangzhen",
    component: () => import("@/views/tongyong"),
    name: "erciwang",
    meta: { title: "二次网仿真", icon: "example" ,name : "erciwang"}
    // hidden: true
  },

  //北京
  {
    path: "/beijing",
    component: () => import("@/views/tongyong"),
    name: "beijing",
    meta: { title: "北京", icon: "example" ,name : "beijing"}
    // hidden: true
  },

  //泰安
  {
    path: "/taian",
    component: () => import("@/views/tongyongnn"),
    name: "taian",
    meta: { title: "泰安", icon: "example" ,name : "taian"}
    // hidden: true
  },

  //uuuiiiii
  // {
  //   path: "/earthui",
  //   component: () => import("@/views/earthui"),
  //   name: "earthui",
  //   meta: { title: "EARTHUI", icon: "example" ,name : "earthui"}
  //   // hidden: true
  // },

  //杭州
  {
    path: "/hangzhou",
    component: () => import("@/views/hangzhou"),
    name: "hangzhou",
    meta: { title: "杭州", icon: "example" ,name : "hangzhou"}
    // hidden: true
  },
  {
    path: "/changzhou",
    component: () => import("@/views/tongyongnnn"),
    name: "changzhou",
    meta: { title: "常州", icon: "example" ,name : "changzhou"}
    // hidden: true
  },
  {
    path: "/jinrong",
    component: () => import("@/views/tongyongnnn"),
    name: "jinrong",
    meta: { title: "金融", icon: "example" ,name : "jinrong"}
    // hidden: true
  },
  
  {
    path: "/wuxi",
    component: () => import("@/views/tongyongnnn"),
    name: "wuxi",
    meta: { title: "无锡", icon: "example" ,name : "wuxi"}
    // hidden: true
  },

  {
    path: "/binhai",
    component: () => import("@/views/tongyongnnn"),
    name: "binhai",
    meta: { title: "滨海", icon: "example" ,name : "binhai"}
    // hidden: true
  },

  //资源
  {
    path: "/ziyuan",
    component: () => import("@/views/tongyong"),
    name: "ziyuan",
    meta: { title: "资源", icon: "example" ,name : "ziyuan"}
    // hidden: true
  },
  //通用
   {
     path: "/tongyong",
     component: () => import("@/views/tongyongnnn"),
     name: "tongyong",
     meta: { title: "通用", icon: "example" ,name : "tongyong"}
     // hidden: true
   },
  //通用
   {
     path: "/yantai",
     component: () => import("@/views/tongyongnn"),
     name: "yantai",
     meta: { title: "烟台", icon: "example" ,name : "yantai"}
     // hidden: true
   },

  { path: "*", redirect: "/404", hidden: true }
];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
